<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr1 = [3,6,5,1];
        var res1 = arr1.sort();
        console.log(res1);

        var arr2 = [4,1,11,31,3];
        // function(){} 是一个比较器函数
        // a>b返回1时，升序
        // a>b返回-1时，降序
        var res2 = arr2.sort(function(a,b){
            if(a>b) {
                return 1;
            } else {
                return -1;
            }
        });
        console.log(res2);

        var arr3 = [1,2,3];
        var res3 = arr3.join();
        var res4 = arr3.join('-');//用-来拼接
        var res5 = arr3.join('');
        var res6 = arr3.toString();
        console.log(res3);
        console.log(res4);
        console.log(res5);
        console.log(res6);
    </script>
</body>
</html>